home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: April 30, 1997
- // Author: mm
- //
- //
-
-
- //
- // Procedure Name:
- // duplicatePreset
- //
- // Description:
- // Performs one or more duplications.
- //
- // Return Value:
- // None.
- //
- global proc duplicatePreset(
- int $count,
- int $copy,
- int $group,
- int $smart,
- int $upstream,
- int $inputConn,
- int $renameChild,
- float $transX, float $transY, float $transZ,
- float $rotatX, float $rotatY, float $rotatZ,
- float $scaleX, float $scaleY, float $scaleZ
- )
- {
- // *NOTE* This command is a complex script and therefore the command
- // echoing cannot be performed using evalEcho because 1) it is
- // too slow when duplicating large numbers of objects and
- // generates too many echoed commands 2) many of the commands
- // involve local variables so the echoed commands are incorrect
- //
- // Therefore, this command uses print to generate its output
- // so you must ensure changes to the script are consistent with
- // the generated output.
- //
- string $cmd = "duplicate -rr";
- string $objects[];
- string $result[];
-
- if ($renameChild) {
- $cmd += " -renameChildren";
- }
-
- if (!$upstream && !$inputConn && !$copy)
- $cmd = "instance";
-
- if ($upstream) {
- // Create duplicates of upstream nodes also.
- //
- $cmd += " -un";
- for ($i = 0; $i < $count; ++$i) {
- $result = eval($cmd);
- for ($obj in $result) $objects[size($objects)] = $obj;
- }
- if ($count == 1) print($cmd+";");
- else print("for ($i=0; $i<"+$count+"; ++$i) "+$cmd+";");
- }
- else if ($inputConn) {
- // Create duplicates of upstream connections (not nodes) also.
- //
- $cmd += " -ic";
- for ($i = 0; $i < $count; ++$i) {
- $result = eval($cmd);
- for ($obj in $result) $objects[size($objects)] = $obj;
- }
- if ($count == 1) print($cmd+";");
- else print("for ($i=0; $i<"+$count+"; ++$i) "+$cmd+";");
- }
- else if ($smart) {
- // Create duplicates
- //
- $cmd += " -st";
- $result = eval($cmd);
- for ($obj in $result) $objects[size($objects)] = $obj;
- print($cmd+";");
- }
- else if ($count > 0) {
- // Create first duplicate
- //
- if ($count > 1) select `ls -sl`; // reset smart transform info
-
- $result = eval($cmd);
- for ($obj in $result) $objects[size($objects)] = $obj;
- print($cmd+";");
-
- if (size($objects) > 0) {
- // Transform it
- //
- if ($scaleX != 1.0 || $scaleY != 1.0 || $scaleZ != 1.0) {
- scale -r $scaleX $scaleY $scaleZ;
- print(" scale -r "+$scaleX+" "+$scaleY+" "+$scaleZ+";");
- }
-
- if ($rotatX != 0.0 || $rotatY != 0.0 || $rotatZ != 0.0) {
- rotate -r $rotatX $rotatY $rotatZ;
- print(" rotate -r "+$rotatX+" "+$rotatY+" "+$rotatZ+";");
- }
-
- if ($transX != 0.0 || $transY != 0.0 || $transZ != 0.0) {
- move -r $transX $transY $transZ;
- print(" move -r "+$transX+" "+$transY+" "+$transZ+";");
- }
-
- // Create remaining duplicates
- //
- $cmd += " -st";
- for ($i = 1; $i < $count; ++$i) {
- $result = eval($cmd);
- for ($obj in $result) $objects[size($objects)] = $obj;
- }
- if ($count>1) print(" for ($i=1; $i<"+$count+"; ++$i) "+$cmd+";");
- }
- }
-
- if (size($objects) > 0) {
- if ($group == 3) {
- string $resultString;
- $resultString = `group $objects`;
-
- // Echo command and result
- print(" group");
- for ($obj in $objects) print(" "+$obj); print(";\n");
- print("// Result: "+$resultString+" //\n");
- } else if ($group == 2) {
- string $objectsUnderWorld[];
- string $parentableObjects[];
- int $i = 0;
- int $j = 0;
- // filter out objects which are already under the world.
- for ($obj in $objects) {
- string $parents[] = `listRelatives -p $obj`;
- if ( size($parents) == 0 ) {
- $objectsUnderWorld[$i] = $obj;
- ++$i;
- }
- else {
- $parentableObjects[$j] = $obj;
- ++$j;
- }
- }
-
- // parent the objects which are not already under the world
- if ( size($parentableObjects) > 0 ) {
- $result = `parent -w $parentableObjects`;
- }
-
- // add the objects already under the world to the list of
- // objects that were parented.
- $i = size($result);
- for ($obj in $objectsUnderWorld) {
- $result[$i] = $obj;
- ++$i;
- }
-
- // Echo parent command
- //
- if ( size($parentableObjects) > 0 ) {
- print(" parent -w");
- for ($obj in $parentableObjects) {
- print(" "+$obj);
- }
- print(";\n");
- }
-
- if ($count > 1) {
- select $result;
-
- if (size($result) > 0) {
- // Echo command and result
- print(" select");
- for ($obj in $result) print(" "+$obj); print(";");
- }
- }
- print("\n");
-
- string $resultStr = "// Result:";
- for ($obj in $result) $resultStr = $resultStr+" "+$obj;
- $resultStr = $resultStr+" //\n";
- print($resultStr);
- } else {
- if ($count > 1) {
- select $objects;
-
- // Echo command and result
- print(" select");
- for ($obj in $objects) print(" "+$obj); print(";");
- }
- print("\n");
-
- // print out the result, making sure it stays in the
- // commandLine output area but using a single print.
- //
- string $resultStr = "// Result:";
- for ($obj in $objects) $resultStr = $resultStr+" "+$obj;
- $resultStr = $resultStr+" //\n";
- print $resultStr;
- }
- }
- }
-